package com.lizhe.springboot_jsp_shiro.utils;

import java.util.Random;

/**
 * 类描述: salt 生成器
 *
 * @author Lz on 2022-05-19
 */
public class SaltUtils {

    public static String getSalt(int n) {
        char[] chars = "ABCDEFGHIJKSDFHDFSGASQWER!@#nopqrstuvwxyz01234567890!@#$%^&*()".toCharArray();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char aChar = chars[new Random().nextInt(chars.length)];
            builder.append(aChar);
        }
        return builder.toString();
    }

    public static void main(String[] args) {
        System.out.println(getSalt(10));
    }
}
